<?php
/**
 * Created by PhpStorm.
 * User: nightelf
 * Date: 2020/12/13
 * Time: 22:16
 */

namespace App\Http\Model;


use Illuminate\Support\Facades\DB;

class WarehouseAdjustInfoModel
{
    public function lists(array $data)
    {
        return DB::table('warehouse_adjust_info')
            ->leftJoin('material as m', 'm.id', '=', 'warehouse_adjust_info.materialId')
            ->leftJoin('material_spec as ms', 'ms.id', '=', 'warehouse_adjust_info.specId')
            ->leftJoin('unit as u', 'u.id', '=', 'warehouse_adjust_info.unitId')
            ->where(function($query) use ($data){
                if(!empty($data['id'])){
                    $query->where('adjustId',$data['id']);
                }
            })
            ->select('m.name as materialName', 'ms.spec', 'u.name as unitName','warehouse_adjust_info.*')
            ->get()->toArray();
    }
}